package lp.polimi.treefinder;

import java.io.IOException;

import lp.polimi.treefinder.utils.FilesUtils;
import android.app.Application;

import com.facebook.SessionDefaultAudience;
import com.sromku.simple.fb.Permissions;
import com.sromku.simple.fb.SimpleFacebook;
import com.sromku.simple.fb.SimpleFacebookConfiguration;
import com.sromku.simple.fb.utils.Logger;

/**
 * Application extension, performing some configuration tasks.
 */
public class TreeFinderApplication extends Application {
	private static final String APP_ID = "545296642222202";
	private static final String APP_NAMESPACE = "tree_finder";
	
	@Override
	public void onCreate() {
		super.onCreate();
		
		try {
			//Creates the tagged leaves XML file.
			FilesUtils.setupLeavesXML(this, false);
			//Save on external storage the default image for untagged stored leaves.
			FilesUtils.setupUnknownLeafImage(this);
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		
		//Simple Facebook API setup.
		
		// set log to true
		Logger.DEBUG_WITH_STACKTRACE = true;

		// initialize facebook configuration
		Permissions[] permissions = new Permissions[]
		{
			Permissions.PUBLISH_STREAM
		};

		SimpleFacebookConfiguration configuration = new SimpleFacebookConfiguration.Builder()
			.setAppId(APP_ID)
			.setNamespace(APP_NAMESPACE)
			.setPermissions(permissions)
			.setDefaultAudience(SessionDefaultAudience.FRIENDS)
			.build();

		SimpleFacebook.setConfiguration(configuration);
		
		
		
		
	}
}
